#include <iostream>
#include <iterator>
using namespace std;

class MyLess
{
public:
	bool operator()(int a1, int a2)
	{
		if ((a1 % 10) < (a2 % 10))
			return true;
		return false;
	}
};

bool MyCompare(int a1, int a2)
{
	if ((a1 % 10) < (a2 % 10))
		return false;
	return true;
}

template<class T, class pred>
T MyMax(T* s, int n, pred op)
{
	T v = s[0];
	for (int i = 1; i < n; ++i)
		if (op(v, s[i]))
			v = s[i];
	return v;
}

int main()
{
	const int SIZE = 5;
	int a[] = { 35,7,13,19,12 };
	cout << MyMax(a, SIZE, MyLess()) << endl;
	cout << MyMax(a, SIZE, MyCompare) << endl;
	return 0;
}